<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.5 of April 16, 2007 on October 18, 2007 at 3:07:30 pm</time-stamp>


<class>
<name>Cargo</name>
<environment>SpaceTrader</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>water waterprice furs fursprice food foodprice ore oreprice games gamesprice firearms firearmsprice medicine medicineprice machines machinesprice narcotics narcoticsprice robots robotsprice totalcargo </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>SpaceTrader</category>
<attributes>
<package>SpaceTrader</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>SpaceTrader.Cargo class</class-id> <category>instance creation</category>

<body package="SpaceTrader" selector="new">new
	"Answer a newly created and initialized instance."

	^super new initialize</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<comment>
<class-id>SpaceTrader.Cargo</class-id>
<body>Cargo contains all of a ship or planet's cargo and its buy or sell price.

Instance Variables:
	firearms	&lt;ArithmeticValue&gt;	Quantity of firearms
	firearmsprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of firearms
	food	&lt;ArithmeticValue&gt;	Quantity of food
	foodprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of food
	furs	&lt;ArithmeticValue&gt;	Quantity of furs
	fursprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of furs
	games	&lt;ArithmeticValue&gt;	Quantity of games
	gamesprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of games
	machines	&lt;ArithmeticValue&gt;	Quantity of machines
	machinesprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of machines
	medicine	&lt;ArithmeticValue&gt;	Quantity of medicine
	medicineprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of medicine
	narcotics	&lt;ArithmeticValue&gt;	Quantity of narcotics
	narcoticsprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of narcotics
	ore	&lt;ArithmeticValue&gt;	Quantity of ore
	oreprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of ore
	robots	&lt;ArithmeticValue&gt;	Quantity of robots
	robotsprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of robots
	totalcargo	&lt;Object&gt;	Total number of cargo items at that ship or planet
	water	&lt;ArithmeticValue&gt;	Quantity of water
	waterprice	&lt;Object&gt;	Sell price (Planet) or last bought price (Ship) of water

</body>
</comment>

<methods>
<class-id>SpaceTrader.Cargo</class-id> <category>initialize-release</category>

<body package="SpaceTrader" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	" *** Edit the following to properly initialize instance variables ***"
	water := 0.
	waterprice := 0.
	furs := 0.
	fursprice := 0.
	food := 0.
	foodprice := 0.
	ore := 0.
	oreprice := 0.
	games := 0.
	gamesprice := 0.
	firearms := 0.
	firearmsprice := 0.
	medicine := 0.
	medicineprice := 0.
	machines := 0.
	machinesprice := 0.
	narcotics := 0.
	narcoticsprice := 0.
	robots := 0.
	robotsprice := 0.
	totalcargo := 0.
	" *** And replace this comment with additional initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SpaceTrader.Cargo</class-id> <category>accessing</category>

<body package="SpaceTrader" selector="firearms">firearms
	^firearms</body>

<body package="SpaceTrader" selector="firearms:">firearms: anObject
	firearms := anObject</body>

<body package="SpaceTrader" selector="firearmsprice">firearmsprice
	^firearmsprice</body>

<body package="SpaceTrader" selector="firearmsprice:">firearmsprice: anObject
	firearmsprice := anObject</body>

<body package="SpaceTrader" selector="food">food
	^food</body>

<body package="SpaceTrader" selector="food:">food: anObject
	food := anObject</body>

<body package="SpaceTrader" selector="foodprice">foodprice
	^foodprice</body>

<body package="SpaceTrader" selector="foodprice:">foodprice: anObject
	foodprice := anObject</body>

<body package="SpaceTrader" selector="furs">furs
	^furs</body>

<body package="SpaceTrader" selector="furs:">furs: anObject
	furs := anObject</body>

<body package="SpaceTrader" selector="fursprice">fursprice
	^fursprice</body>

<body package="SpaceTrader" selector="fursprice:">fursprice: anObject
	fursprice := anObject</body>

<body package="SpaceTrader" selector="games">games
	^games</body>

<body package="SpaceTrader" selector="games:">games: anObject
	games := anObject</body>

<body package="SpaceTrader" selector="gamesprice">gamesprice
	^gamesprice</body>

<body package="SpaceTrader" selector="gamesprice:">gamesprice: anObject
	gamesprice := anObject</body>

<body package="SpaceTrader" selector="machines">machines
	^machines</body>

<body package="SpaceTrader" selector="machines:">machines: anObject
	machines := anObject</body>

<body package="SpaceTrader" selector="machinesprice">machinesprice
	^machinesprice</body>

<body package="SpaceTrader" selector="machinesprice:">machinesprice: anObject
	machinesprice := anObject</body>

<body package="SpaceTrader" selector="medicine">medicine
	^medicine</body>

<body package="SpaceTrader" selector="medicine:">medicine: anObject
	medicine := anObject</body>

<body package="SpaceTrader" selector="medicineprice">medicineprice
	^medicineprice</body>

<body package="SpaceTrader" selector="medicineprice:">medicineprice: anObject
	medicineprice := anObject</body>

<body package="SpaceTrader" selector="narcotics">narcotics
	^narcotics</body>

<body package="SpaceTrader" selector="narcotics:">narcotics: anObject
	narcotics := anObject</body>

<body package="SpaceTrader" selector="narcoticsprice">narcoticsprice
	^narcoticsprice</body>

<body package="SpaceTrader" selector="narcoticsprice:">narcoticsprice: anObject
	narcoticsprice := anObject</body>

<body package="SpaceTrader" selector="ore">ore
	^ore</body>

<body package="SpaceTrader" selector="ore:">ore: anObject
	ore := anObject</body>

<body package="SpaceTrader" selector="oreprice">oreprice
	^oreprice</body>

<body package="SpaceTrader" selector="oreprice:">oreprice: anObject
	oreprice := anObject</body>

<body package="SpaceTrader" selector="robots">robots
	^robots</body>

<body package="SpaceTrader" selector="robots:">robots: anObject
	robots := anObject</body>

<body package="SpaceTrader" selector="robotsprice">robotsprice
	^robotsprice</body>

<body package="SpaceTrader" selector="robotsprice:">robotsprice: anObject
	robotsprice := anObject</body>

<body package="SpaceTrader" selector="totalcargo">totalcargo
	^totalcargo</body>

<body package="SpaceTrader" selector="totalcargo:">totalcargo: anObject
	totalcargo := anObject</body>

<body package="SpaceTrader" selector="water">water
	^water</body>

<body package="SpaceTrader" selector="water:">water: anObject
	water := anObject</body>

<body package="SpaceTrader" selector="waterprice">waterprice
	^waterprice</body>

<body package="SpaceTrader" selector="waterprice:">waterprice: anObject
	waterprice := anObject</body>
</methods>

<methods>
<class-id>SpaceTrader.Cargo</class-id> <category>calculating</category>

<body package="SpaceTrader" selector="NetWorth">NetWorth
	"Calculate the total worth of all of the cargo"
	|total|
	total :=
		(water * waterprice) +
		(furs * fursprice) +
		(food * foodprice) +
		(ore * oreprice) +
		(games * gamesprice) +
		(firearms * firearmsprice) +
		(medicine * medicineprice) +
		(machines * machinesprice) +
		(narcotics * narcoticsprice) +
		(robots * robotsprice).
	^total</body>
</methods>

</st-source>
